package com.cvnert.testplatform.controller;


import com.cvnert.testplatform.domain.vo.DefectListVo;
import com.cvnert.testplatform.domain.vo.DefectVo;
import com.cvnert.testplatform.domain.vo.TaskVo;
import com.cvnert.testplatform.service.DefectService;
import com.cvnert.testplatform.utils.ResultJson;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@CrossOrigin(origins = "*")
@RestController
@RequestMapping("/defect")

public class DefectController {
    @Resource
    private DefectService defectService;

    @PostMapping("/addDefect")
    public ResultJson<Object> getTaskList(@RequestBody DefectVo defectVo){
        return ResultJson.success(defectService.addDefect(defectVo));
    }

    @GetMapping("/deleteDefect/{did}")
    public ResultJson<Object> deleteTask(@PathVariable Integer did){
        return ResultJson.success(defectService.deleteDefect(did));
    }

    @PostMapping("/updateDefect")
    public ResultJson<Object> updateTask(@RequestBody DefectVo defectVo){
        return ResultJson.success(defectService.updateDefect(defectVo));
    }
    @PostMapping("/getDefectList")
    public ResultJson<Object> getTaskList(@RequestBody DefectListVo defectListVo){
        return ResultJson.success(defectService.getDefectList(defectListVo));
    }

    @GetMapping("/getDefectDetail/{did}")
    public ResultJson<Object> getTaskDetail(@PathVariable Integer did){
        return ResultJson.success(defectService.getDefectDetail(did));
    }

    @PostMapping("/getDefectCount")
    public ResultJson<Object> getTaskCount(@RequestBody DefectListVo defectListVo){
        return ResultJson.success(defectService.getDefectCount(defectListVo));
    }

}
